1 <?php
2 session_start(); // Use session variable on this page. This function must put on the top of page.
3 if(!isset($_SESSION['username']) || $_SESSION['usertype'] !='admin'){ // if session variable "username" does not exist.
4 header("location:index.php?msg=Please%20login%20to%20access%20admin%20area%20!"); // Re-direct to index.php
5 }
6 else
7 {
8 include_once "db.php";
9 error_reporting (E_ALL ^ E_NOTICE);
10
11
12 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
13 "http://www.w3.org/TR/html4/loose.dtd">
14 <html>
15 <head>
16 <title>Welcome to Stock Management System !</title>
17 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
18 <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
19 <link rel="stylesheet" href="css/template.css" type="text/css" media="screen" title="no title" charset="utf-8" />
20 <script src="js/jquery.min.js" type="text/javascript"></script>
21
22
23
24
25
26 <script LANGUAGE="JavaScript">
27 <!--
28 // Nannette Thacker http://www.shiningstar.net
29 function confirmSubmit()
30 {
31 var agree=confirm("Are you sure you wish to Delete this Entry?");
32 if (agree)
33 return true ;
34 else
35 return false ;
36 }
37
38 function confirmDeleteSubmit()
39 {
40 var agree=confirm("Are you sure you wish to Delete Seletec Record?");
41 if (agree)
42
43 document.deletefiles.submit();
44 else
45 return false ;
46 }
47
48
49 function checkAll()
50 {
51
52 var field=document.forms.deletefiles;
53 for (i = 0; i < field.length; i++)
54 field[i].checked = true ;
55 }
56
57 function uncheckAll()
58 {
59 var field=document.forms.deletefiles;
60 for (i = 0; i < field.length; i++)
61 field[i].checked = false ;
62 }
63 // -->
64 </script>
65
66
67 <script src="js/jquery.validationEngine-en.js" type="text/javascript"></script>
68 <script src="js/jquery.validationEngine.js" type="text/javascript"></script>
69 <script src="js/jquery.hotkeys-0.7.9.js"></script>
70 <!-- AJAX SUCCESS TEST FONCTION
71 <script>function callSuccessFunction(){alert("success executed")}
72 function callFailFunction(){alert("fail executed")}
73 </script>
74 -->
75
76 <script>
77
78
79
80
81
82 $(document).ready(function() {
83 // SUCCESS AJAX CALL, replace "success: false," by: success : function() { callSuccessFunction() },
84 $("#name").focus();
85 $("#form1").validationEngine(),
86
87 jQuery(document).bind('keydown', 'Ctrl+s',function() {
88 $('#form1').submit();
89 return false;
90 });
91
92 jQuery(document).bind('keydown', 'Ctrl+r',function() {
93 $('#form1').reset();
94 return false;
95 });
96 jQuery(document).bind('keydown', 'Ctrl+a',function() {
97 window.location = "addstock.php";
98 return false;
99 });
100 jQuery(document).bind('keydown', 'Ctrl+0',function() {
101 window.location = "admin.php";
102 return false;
103 });
104 jQuery(document).bind('keydown', 'Ctrl+1',function() {
105 window.location = "add_purchase.php";
106 return false;
107 });
108 jQuery(document).bind('keydown', 'Ctrl+2',function() {
109 window.location = "add_stock_sales.php";
110 return false;
111 });
112 jQuery(document).bind('keydown', 'Ctrl+3',function() {
113 window.location = "add_stock_details.php";
114 return false;
115 });
116 jQuery(document).bind('keydown', 'Ctrl+4',function() {
117 window.location = "add_category.php";
118 return false;
119 });
120 jQuery(document).bind('keydown', 'Ctrl+5',function() {
121 window.location = "add_supplier_details.php";
122 return false;
123 });
124 jQuery(document).bind('keydown', 'Ctrl+6',function() {
125 window.location = "add_customer_details.php";
126 return false;
127 });
128 jQuery(document).bind('keydown', 'Ctrl+7',function() {
129 window.location = "view_stock_entries.php";
130 return false;
131 });
132 jQuery(document).bind('keydown', 'Ctrl+8',function() {
133 window.location = "view_stock_sales.php";
134 return false;
135 });
136 jQuery(document).bind('keydown', 'Ctrl+9',function() {
137 window.location = "view_stock_details.php";
138 return false;
139 });
140 //$.validationEngine.loadValidation("#date")
141 //alert($("#formID").validationEngine({returnIsValid:true}))
142 //$.validationEngine.buildPrompt("#date","This is an example","error") // Exterior prompt build example // input prompt close example
143 //$.validationEngine.closePrompt(".formError",true) // CLOSE ALL OPEN PROMPTS
144 });
145 </script>
146 <style type="text/css">
147 <!--
148 body {
149 margin-left: 0px;
150 margin-top: 0px;
151 margin-right: 0px;
152 margin-bottom: 0px;
153 background-color: #FFFFFF;
154 }
155
156 *{
157 padding: 0px;
158 margin: 0px;
159 }
160 #vertmenu {
161 font-family: Verdana, Arial, Helvetica, sans-serif;
162 font-size: 100%;
163 width: 160px;
164 padding: 0px;
165 margin: 0px;
166 }
167
168 #vertmenu h1 {
169 display: block;
170 background-color:#FF9900;
171 font-size: 90%;
172 padding: 3px 0 5px 3px;
173 border: 1px solid #000000;
174 color: #333333;
175 margin: 0px;
176 width:159px;
177 }
178
179 #vertmenu ul {
180 list-style: none;
181 margin: 0px;
182 padding: 0px;
183 border: none;
184 }
185 #vertmenu ul li {
186 margin: 0px;
187 padding: 0px;
188 }
189 #vertmenu ul li a {
190 font-size: 80%;
191 display: block;
192 border-bottom: 1px dashed #C39C4E;
193 padding: 5px 0px 2px 4px;
194 text-decoration: none;
195 color: #666666;
196 width:160px;
197 }
198
199 #vertmenu ul li a:hover, #vertmenu ul li a:focus {
200 color: #000000;
201 background-color: #eeeeee;
202 }
203 .style1 {color: #000000}
204 div.pagination {
205
206 padding: 3px;
207
208 margin: 3px;
209
210 }
211
212
213
214 div.pagination a {
215
216 padding: 2px 5px 2px 5px;
217
218 margin: 2px;
219
220 border: 1px solid #AAAADD;
221
222
223
224 text-decoration: none; /* no underline */
225
226 color: #000099;
227
228 }
229
230 div.pagination a:hover, div.pagination a:active {
231
232 border: 1px solid #000099;
233
234
235
236 color: #000;
237
238 }
239
240 div.pagination span.current {
241
242 padding: 2px 5px 2px 5px;
243
244 margin: 2px;
245
246 border: 1px solid #000099;
247
248
249
250 font-weight: bold;
251
252 background-color: #000099;
253
254 color: #FFF;
255
256 }
257
258 div.pagination span.disabled {
259
260 padding: 2px 5px 2px 5px;
261
262 margin: 2px;
263
264 border: 1px solid #EEE;
265
266
267
268 color: #DDD;
269
270 }
271
272
273 -->
274 </style>
275 </head>
276
277 <body>
278 <table width="100%" border="0" cellspacing="0" cellpadding="0">
279 <tr>
280 <td align="center" valign="top"><table width="960" border="0" cellspacing="0" cellpadding="0">
281 <tr>
282 <td><table width="960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
283 <tr>
284 <td height="90" align="left" valign="top"><img src="images/topbanner.jpg" width="960" height="82"></td>
285 </tr>
286 <tr>
287 <td height="800" align="left" valign="top"><table width="960" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
288 <tr>
289 <td width="130" align="left" valign="top">
290
291 <br>
292
293 <strong>Welcome <font color="#3399FF"><?php echo $_SESSION['username']; ?> !</font></strong><br> <br>
294 <table width="100%" border="0" cellspacing="0" cellpadding="0">
295 <tr>
296 <td align="center"><a href="admin.php"><img src="images/home.png" width="130" height="99" border="0"></a></td>
297 </tr>
298 <tr>
299 <td align="center"> </td>
300 </tr>
301 <tr>
302 <td align="center"><a href="add_purchase.php"><img src="images/purchase.png" width="130" height="124" border="0"></a></td>
303 </tr>
304 <tr>
305 <td align="center"> </td>
306 </tr>
307 <tr>
308 <td align="center"><a href="add_stock_sales.php"><img src="images/sales.png" width="146" height="111" border="0"></a></td>
309 </tr>
310 <tr>
311 <td align="center"> </td>
312 </tr>
313 <tr>
314 <td align="center"><a href="report.php"><img src="images/reports.png" width="131" height="142" border="0"></a></td>
315 </tr>
316 <tr>
317 <td align="center"> </td>
318 </tr>
319 <tr>
320 <td align="center"> </td>
321 </tr>
322 <tr>
323 <td align="center"> </td>
324 </tr>
325 </table>
326
327
328
329
330
331 </td> <td height="500" align="center" valign="top">
332 <table width="100%" border="0" cellspacing="0" cellpadding="0">
333 <tr>
334 <td><a href="add_stock_details.php"><img src="images/addstockdetails.png" width="67" height="62" border="0"></a></td>
335 <td><a href="add_supplier_details.php"><img src="images/supplier.png" width="67" height="54" border="0"></a></td>
336 <td><a href="add_customer_details.php"><img src="images/customer.png" width="67" height="54" border="0"></a></td>
337 <td><a href="add_category.php"><img src="images/categories.png" width="67" height="54" border="0"></a></td>
338 <td><a href="view_stock_sales.php"><img src="images/vsales.png" width="67" height="54" border="0"></a></td>
339 <td><a href="view_stock_entries.php"><img src="images/vpurchase.png" width="67" height="54" border="0"></a></td>
340 <td><a href="view_stock_details.php"><img src="images/stockdetails.png" width="67" height="54" border="0"></a></td>
341 <td><a href="view_stock_availability.php"><img src="images/savail.png" width="67" height="54" border="0"></a></td>
342 <td align="left" valign="top"><a href="view_customer_details.php"><img src="images/customers.png" width="94" height="22" border="0"></a><br> <a href="view_supplier_details.php"><img src="images/suppliers.png" width="94" height="22" border="0"></a><br>
343 <a href="view_payments.php"><img src="images/payments.png" width="94" height="22" border="0"></a></td>
344 <td align="left" valign="top"><a href="view_stock_sales_payments.php"><img src="images/outstanding.png" width="94" height="22" border="0"></a><br> <a href="view_stock_entries_payments.php"><img src="images/pendings.png" width="94" height="22" border="0"></a><br>
345 <a href="logout.php"><img src="images/logout.png" width="94" height="22" border="0"></a></td>
346 </tr>
347 </table>
348 <br>
349 <br>
350 <table width="700" border="0" cellspacing="0" cellpadding="0">
351 <tr>
352 <td><form action="" method="post" name="search" >
353 <input name="searchtxt" type="text">
354 <input name="Search" type="submit" value="Search">
355 </form></td>
356 <td><form action="" method="get" name="page">
357 Page per Record<input name="limit" type="text" style="margin-left:5px;" value="<?php if(isset($_GET['limit'])) echo $_GET['limit']; else echo "10"; ?>" size="3" maxlength="3">
358 <input name="go" type="submit" value="Go">
359 <input type="button" name="selectall" value="SelectAll" onClick="checkAll()" style="margin-left:5px;"/>
360 <input type="button" name="unselectall" value="DeSelectAll" onClick="uncheckAll()" style="margin-left:5px;" />
361 <input name="dsubmit" type="button" value="Delete Selected" style="margin-left:5px;" onclick="return confirmDeleteSubmit()"/></form></td>
362 </tr>
363 </table>
364
365
366 <?php
367
368
369
370 $SQL = "SELECT * FROM stock_details";
371 if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
372 {
373
374 $SQL = "SELECT COUNT(*) as num FROM stock_details WHERE stock_name LIKE '%".$_POST['searchtxt']."%' OR supplier_id LIKE '%".$_POST['searchtxt']."%' OR category LIKE '%".$_POST['searchtxt']."%' OR date LIKE '%".$_POST['searchtxt']."%'";
375
376
377 }
378
379 $tbl_name="stock_details"; //your table name
380
381 // How many adjacent pages should be shown on each side?
382
383 $adjacents = 3;
384
385
386
387 /*
388
389 First get total number of rows in data table.
390
391 If you have a WHERE clause in your query, make sure you mirror it here.
392
393 */
394
395
396
397
398 $query = "SELECT COUNT(*) as num FROM $tbl_name";
399 if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
400 {
401
402 $query = "SELECT COUNT(*) as num FROM stock_details WHERE stock_name LIKE '%".trim($_POST['searchtxt'])."%' OR supplier_id LIKE '%".trim($_POST['searchtxt'])."%' OR category LIKE '%".trim($_POST['searchtxt'])."%' OR date LIKE '%".trim($_POST['searchtxt'])."%'";
403
404
405
406 }
407
408
409 $total_pages = mysql_fetch_array(mysql_query($query));
410
411 $total_pages = $total_pages[num];
412
413
414
415 /* Setup vars for query. */
416
417 $targetpage = "view_stock_details.php"; //your file name (the name of this file)
418
419
420 $limit = 10; //how many items to show per page
421
422 if(isset($_GET['limit']))
423 $limit=$_GET['limit'];
424
425 $page = $_GET['page'];
426
427 if($page)
428
429 $start = ($page - 1) * $limit; //first item to display on this page
430
431 else
432
433 $start = 0; //if no page var is given, set start to 0
434
435
436
437 /* Get data. */
438
439 $sql = "SELECT * FROM stock_details ORDER BY date desc LIMIT $start, $limit ";
440 if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
441 {
442
443 $sql = "SELECT * FROM stock_details WHERE stock_name LIKE '%".trim($_POST['searchtxt'])."%' OR supplier_id LIKE '%".trim($_POST['searchtxt'])."%' OR category LIKE '%".trim($_POST['searchtxt'])."%' OR date LIKE '%".trim($_POST['searchtxt'])."%' ORDER BY date desc LIMIT $start, $limit ";
444
445
446 }
447
448
449
450 $result = mysql_query($sql);
451
452
453
454 /* Setup page vars for display. */
455
456 if ($page == 0) $page = 1; //if no page var is given, default to 1.
457
458 $prev = $page - 1; //previous page is page - 1
459
460 $next = $page + 1; //next page is page + 1
461
462 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
463
464 $lpm1 = $lastpage - 1; //last page minus 1
465
466
467
468 /*
469
470 Now we apply our rules and draw the pagination object.
471
472 We're actually saving the code to a variable in case we want to draw it more than once.
473
474 */
475
476 $pagination = "";
477
478 if($lastpage > 1)
479
480 {
481
482 $pagination .= "<div class=\"pagination\">";
483
484 //previous button
485
486 if ($page > 1)
487
488 $pagination.= "<a href=\"$targetpage?page=$prev&limit=$limit\">« previous</a>";
489
490 else
491
492 $pagination.= "<span class=\"disabled\">« previous</span>";
493
494
495
496 //pages
497
498 if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
499
500 {
501
502 for ($counter = 1; $counter <= $lastpage; $counter++)
503
504 {
505
506 if ($counter == $page)
507
508 $pagination.= "<span class=\"current\">$counter</span>";
509
510 else
511
512 $pagination.= "<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
513
514 }
515
516 }
517
518 elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
519
520 {
521
522 //close to beginning; only hide later pages
523
524 if($page < 1 + ($adjacents * 2))
525
526 {
527
528 for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
529
530 {
531
532 if ($counter == $page)
533
534 $pagination.= "<span class=\"current\">$counter</span>";
535
536 else
537
538 $pagination.= "<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
539
540 }
541
542 $pagination.= "...";
543
544 $pagination.= "<a href=\"$targetpage?page=$lpm1&limit=$limit\">$lpm1</a>";
545
546 $pagination.= "<a href=\"$targetpage?page=$lastpage&limit=$limit\">$lastpage</a>";
547
548 }
549
550 //in middle; hide some front and some back
551
552 elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
553
554 {
555
556 $pagination.= "<a href=\"$targetpage?page=1&limit=$limit\">1</a>";
557
558 $pagination.= "<a href=\"$targetpage?page=2&limit=$limit\">2</a>";
559
560 $pagination.= "...";
561
562 for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
563
564 {
565
566 if ($counter == $page)
567
568 $pagination.= "<span class=\"current\">$counter</span>";
569
570 else
571
572 $pagination.= "<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
573
574 }
575
576 $pagination.= "...";
577
578 $pagination.= "<a href=\"$targetpage?page=$lpm1&limit=$limit\">$lpm1</a>";
579
580 $pagination.= "<a href=\"$targetpage?page=$lastpage&limit=$limit\">$lastpage</a>";
581
582 }
583
584 //close to end; only hide early pages
585
586 else
587
588 {
589
590 $pagination.= "<a href=\"$targetpage?page=1&limit=$limit\">1</a>";
591
592 $pagination.= "<a href=\"$targetpage?page=2&limit=$limit\">2</a>";
593
594 $pagination.= "...";
595
596 for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
597
598 {
599
600 if ($counter == $page)
601
602 $pagination.= "<span class=\"current\">$counter</span>";
603
604 else
605
606 $pagination.= "<a href=\"$targetpage?page=$counter&limit=$limit\">$counter</a>";
607
608 }
609
610 }
611
612 }
613
614
615
616 //next button
617
618 if ($page < $counter - 1)
619
620 $pagination.= "<a href=\"$targetpage?page=$next&limit=$limit\">next »</a>";
621
622 else
623
624 $pagination.= "<span class=\"disabled\">next »</span>";
625
626 $pagination.= "</div>\n";
627
628 }
629
630 ?>
631 <?php if(isset($_GET['msg'])) echo "Record ID:[ ".$_GET['id']." ] <center>".$_GET['msg']."</center>";
632
633 if(isset($_GET['cmsg'])) echo "<center>".$_GET['cmsg']."</center>";
634 ?>
635
636
637
638 <form name="deletefiles" action="deleteselected.php" method="post">
639 <input name="table" type="hidden" value="stock_details">
640 <input name="return" type="hidden" value="view_stock_details.php">
641
642
643 <table width="700" border="0" cellspacing="0" cellpadding="0">
644
645 <tr>
646
647 <td bgcolor="#0099FF"><div align="center"><strong><span class="style1">View Stock Details </span></strong></div></td>
648
649 </tr>
650
651 <tr>
652
653 <td> </td>
654
655 </tr>
656
657 <tr>
658
659 <td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
660
661 <tr>
662
663 <td width="100"><strong>Stock Name </strong></td>
664
665 <td width="100"><strong>Date</strong></td>
666
667 <td width="100"><strong>Supplier</strong></td>
668
669 <td width="100"><strong>Selling <br>
670 Price <br>
671 </strong></td>
672
673 <td width="100"><strong>Avail<br>
674 Stock<br>
675 </strong></td>
676
677 <td width="100"><strong>View/Edit</strong></td>
678 <td width="100"><strong>Delete</strong></td>
679 <td width="100"><strong>Select</strong></td>
680 </tr>
681
682
683
684
685
686 <?php
687
688
689
690 while($row = mysql_fetch_array($result))
691
692 {
693
694
695
696 $mysqldate=$row['date'];
697
698 $phpdate = strtotime( $mysqldate );
699
700 $phpdate = date("d/m/Y",$phpdate);
701
702
703
704 ?>
705
706 <tr>
707
708
709
710 <td width="100"><?php echo $row['stock_name']; ?></td>
711
712 <td width="100"><?php echo $phpdate; ?></td>
713
714 <td width="100"><?php echo $row['supplier_id']; ?></td>
715
716
717
718 <td width="100"><?php echo $row['selling_price']; ?></td>
719
720 <td width="100"><?php $quantity = $db->queryUniqueValue("SELECT quantity FROM stock_avail WHERE name='".$row['stock_name']."'"); echo $quantity; ?></td>
721
722 <td width="100"> <a href="update_stock_details.php?id=<?php echo $row['id'];?>"><img src="images/edit-icon.png" border="0" alt="delete"></a></td>
723 <td width="100"><a onclick="return confirmSubmit()"
724 href="delete.php?id=<?php echo $row['id']; ?>&table=stock_details&return=view_stock_details.php"><img src="images/delete.png" border="0" alt="delete"></a></td>
725 <td width="100"> <input type="checkbox" value="<?php echo $row['id']; ?>" name="checklist[]" /></td>
726 </tr>
727
728
729
730
731
732
733
734
735
736 <?php
737
738
739
740
741
742 }
743
744
745
746
747
748
749
750
751
752
753
754
755
756 ?>
757
758
759
760
761
762
763
764
765
766
767
768 </table></td>
769
770 </tr>
771
772 <tr>
773
774 <td> </td>
775
776 </tr>
777
778 <tr>
779
780 <td align="center"> </td>
781
782 </tr>
783
784 <tr>
785
786 <td align="center"><div style="margin-left:20px;"><?php echo $pagination; ?></div></td>
787
788 </tr>
789
790 <tr>
791
792 <td align="center"> </td>
793
794 </tr>
795
796 <tr>
797
798 <td> </td>
799
800 </tr>
801
802 <tr>
803
804 <td align="center"> </td>
805
806 </tr>
807
808 <tr>
809
810 <td> </td>
811
812 </tr>
813
814 </table>
815
816 </form>
817
818
819
820
821
822
823
824 </td>
825
826 </tr>
827
828 </table>
829
830
831
832 </td>
833 </tr>
834 </table>
835
836 </td>
837 </tr>
838 <tr>
839 <td height="30" align="center" bgcolor="#72C9F4"><span class="style1"><a href="http://www.pluskb.com">Developed by PlusKB Innovations</a></span></td>
840 </tr>
841 </table></td>
842 </tr>
843 </table></td>
844 </tr>
845 </table>
846
847 </body>
848 </html>
849 <?php
850 }
851 ?>